<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8" />
    <title>首页</title>
    <link rel="stylesheet" type="text/css" media="all"
          href="/webjars/bootstrap/css/bootstrap.min.css" th:href="@{/webjars/bootstrap/css/bootstrap.min.css}" />
</head>
<body>
Hello, <shiro:principal/>, how are you today?
<shiro:hasRole name="ADMIN">
    <br />I'm fine, 我拥有管理员角色--<span th:text="${userName}"></span>
</shiro:hasRole>
<!--退出登陆按钮-->
<button id="logoutBtn" type="button" style="width:280px;" class="btn btn-default">退出登录</button>
</body>
<script th:src="@{/webjars/jquery/jquery.min.js}"></script>
<script th:src="@{/webjars/bootstrap/js/bootstrap.min.js}"></script>
<script type="text/javascript">
    (function() {
        var OriginTitile = document.title, titleTime;
        document.addEventListener('visibilitychange', function() {
            if (document.hidden) {
                document.title = '死鬼又去哪里了！';
                clearTimeout(titleTime);
            } else {
                document.title = '(つェ⊂)咦!又好了!';
                titleTime = setTimeout(function() {
                    document.title = OriginTitile;
                },2000);
            }
        });
    })();
    $(function (){
        $('#logoutBtn').click(function () {
            document.location.href='/logout';
        })
        $.getJSON('/online',{},function(s){
            console.log(s);
            if(s.message){
                alert(s.message);
                document.location.href='/logout';
            }
        })
    });
</script>

</html>